import os
import uiautomation
from config.config import DATA_PATH
from page.index import IndexPage
from page.住院医生站.住院医生站.zhuyuanyishengzhan__page import zhuyuanyishengzhan


from tools.sjqd_way import read_data_from_excel


class Tiaoshi():
    his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
    his.SetFocus()
    def tuikuanchuli(self):
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "测试患者")
        name = self.data[0][0]
        ap = IndexPage()
        bp = zhuyuanyishengzhan()
        ap.click_zyysz1_btn()
        ap.click_zyysz2_btn()  # 点击住院医生站
        bp.input_hzxm(name)  # 输入患者姓名
        bp.click_ssbr('全院')#选择所属患者
        bp.click_zyzt('在院')#选择在院状态
        bp.click_cx_btn()#点击查询按钮
        bp.click_hz1()#点击患者1
        bp.click_cqyz()#点击长期医嘱
        bp.add_xmsjz(5)#添加新数据组
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "长期医嘱")
        yznr1, yf1, pc1 = self.data[0]
        yznr2, yf2, pc2 = self.data[1]
        yznr3, yf3, pc3 = self.data[2]
        yznr4, yf4, pc4 = self.data[3]
        yznr5, yf5, pc5 = self.data[4]
        bp.add_cqxm1(yznr1,yf1,pc1)
        bp.add_cqxm2(yznr2, yf2, pc2)
        bp.add_cqxm3(yznr3, yf3, pc3)
        bp.add_cqxm4(yznr4, yf4, pc4)
        bp.add_cqxm5(yznr5, yf5, pc5)
        bp.click_zc_btn()#点击暂存
        bp.click_lsyz()#点击零时医嘱
        bp.add_xmsjz(5)  # 添加新数据组
        bp.zhengjiaxiangmu.Refind()
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "临时医嘱")
        yznr1, yf1, pc1 = self.data[0]
        yznr2, yf2, pc2 = self.data[1]
        yznr3, yf3, pc3 = self.data[2]
        yznr4, yf4, pc4 = self.data[3]
        yznr5, yf5, pc5 = self.data[4]
        bp.add_lsxm1(yznr1, yf1, pc1)
        bp.add_lsxm2(yznr2, yf2, pc2)
        bp.add_lsxm3(yznr3, yf3, pc3)
        bp.add_lsxm4(yznr4, yf4, pc4)
        bp.add_lsxm5(yznr5, yf5, pc5)


if __name__ == '__main__':
    Tiaoshi().tuikuanchuli()